﻿<UserControl x:Class="StockTraderRI.Modules.Position.PositionSummary.PositionPieChartView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:charting="clr-namespace:Microsoft.Windows.Controls.DataVisualization.Charting;assembly=Microsoft.Windows.Controls.DataVisualization"
    xmlns:datavis="clr-namespace:Microsoft.Windows.Controls.DataVisualization;assembly=Microsoft.Windows.Controls.DataVisualization"
    Height="170">
    <UserControl.Resources>
        <!-- By convention every view inside the ResearchControl (ResearchRegion) has to declare 
             a DataTemplate with the "HeaderIcon" key which defines the icon on the Header -->
        <DataTemplate x:Key="HeaderIcon">
            <Grid Margin="15,5,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="15.031" Height="15.055">
                <Ellipse Margin="0,0,0.031,0.055" Fill="{x:Null}" Stroke="#FFFFFFFF" StrokeThickness="2"/>
                <Path Margin="6.531,6.43,0,0" Fill="{x:Null}" Stretch="Fill" Stroke="#FFFFFFFF" StrokeThickness="2" Data="M66.625,440 L60.125,440 60.125,446.625"/>
            </Grid>
        </DataTemplate>

        <Style x:Key="ProportionsPieChart" TargetType="charting:PieSeries">
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="charting:PieSeries">
                        <Canvas x:Name="PlotArea"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ProportionsChartContainer" TargetType="charting:Chart">
            <Setter Property="BorderBrush" Value="Black"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="StylePalette">
                <Setter.Value>
                    <datavis:StylePalette>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFB9D6F7"/>
                                        <GradientStop Color="#FF284B70" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFFBB7B5"/>
                                        <GradientStop Color="#FF702828" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFB8C0AC"/>
                                        <GradientStop Color="#FF5F7143" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFFDE79C"/>
                                        <GradientStop Color="#FFF6BC0C" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFA9A3BD"/>
                                        <GradientStop Color="#FF382C6C" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFB1A1B1"/>
                                        <GradientStop Color="#FF50224F" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FF9DC2B3"/>
                                        <GradientStop Color="#FF1D7554" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFB5B5B5"/>
                                        <GradientStop Color="#FF4C4C4C" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FF98C1DC"/>
                                        <GradientStop Color="#FF0271AE" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFC1C0AE"/>
                                        <GradientStop Color="#FF706E41" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFADBDC0"/>
                                        <GradientStop Color="#FF446A73" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FF2F8CE2"/>
                                        <GradientStop Color="#FF0C3E69" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFDCDCDC"/>
                                        <GradientStop Color="#FF757575" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFF4F4F4"/>
                                        <GradientStop Color="#FFB7B7B7" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="Control">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <RadialGradientBrush>
                                        <RadialGradientBrush.RelativeTransform>
                                            <TransformGroup>
                                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.09" ScaleY="1.819"/>
                                                <TranslateTransform X="-0.425" Y="-0.486"/>
                                            </TransformGroup>
                                        </RadialGradientBrush.RelativeTransform>
                                        <GradientStop Color="#FFF4F4F4"/>
                                        <GradientStop Color="#FFA3A3A3" Offset="1"/>
                                    </RadialGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </datavis:StylePalette>
                </Setter.Value>
            </Setter>
            <Setter Property="TitleStyle">
                <Setter.Value>
                    <Style TargetType="datavis:Title">
                        <Setter Property="FontSize" Value="16"/>
                        <Setter Property="HorizontalAlignment" Value="Center"/>
                        <Setter Property="Margin" Value="0,10,0,10"/>
                    </Style>
                </Setter.Value>
            </Setter>
            <Setter Property="LegendStyle">
                <Setter.Value>
                    <Style TargetType="datavis:Legend">
                        <Setter Property="Margin" Value="15,0,15,0"/>
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        <Setter Property="BorderBrush" Value="#FFDBDBDB"/>
                        <Setter Property="Background">
                            <Setter.Value>
                                <LinearGradientBrush EndPoint="0.442,0.005" StartPoint="0.558,0.995">
                                    <GradientStop Color="#FFDBDBDB"/>
                                    <GradientStop Color="#FFFFFFFF" Offset="1"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>
            <Setter Property="ChartAreaStyle">
                <Setter.Value>
                    <Style TargetType="Grid">
                        <Setter Property="MinWidth" Value="100"/>
                        <Setter Property="MinHeight" Value="75"/>
                    </Style>
                </Setter.Value>
            </Setter>
            <Setter Property="PlotAreaStyle">
                <Setter.Value>
                    <Style TargetType="Grid">
                        <Setter Property="Background">
                            <Setter.Value>
                                <LinearGradientBrush EndPoint="0.457,0.296" StartPoint="0.459,1.296">
                                    <GradientStop Color="#FFCBCBCB"/>
                                    <GradientStop Color="#FFFFFFFF" Offset="1"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="charting:Chart">
                        <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="0">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <datavis:Title Style="{TemplateBinding TitleStyle}" Content="{TemplateBinding Title}"/>
                                <Grid Grid.Row="1">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}" RenderTransformOrigin="0.5,0.5" Height="120">
                                    	<Grid.RenderTransform>
                                    		<TransformGroup>
                                    			<ScaleTransform/>
                                    			<SkewTransform/>
                                    			<RotateTransform/>
                                    			<TranslateTransform Y="-21"/>
                                    		</TransformGroup>
                                    	</Grid.RenderTransform>
                                        <Grid x:Name="PlotArea" Style="{TemplateBinding PlotAreaStyle}" Background="{x:Null}">
                                            <Grid x:Name="GridLinesContainer"/>
                                            <Grid x:Name="SeriesContainer"/>
                                            <Border BorderBrush="{x:Null}" BorderThickness="1"/>
                                        </Grid>
                                    </Grid>
                                </Grid>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Border BorderThickness="0,0,0,1" BorderBrush="#FFFFFFFF" Padding="10,10,10,10">
    <StackPanel>
		<TextBlock Text="PIE CHART" Style="{StaticResource TextBlockSectionTitle}" AutomationProperties.AutomationId="PieChartTextBlock" />
            <charting:Chart Style="{StaticResource ProportionsChartContainer}" BorderBrush="{x:Null}" Height="Auto" Width="Auto">
                <charting:Chart.Series>
                    <charting:PieSeries ItemsSource="{Binding Position.Items}" 
                            IndependentValueBinding="{Binding TickerSymbol}"
                            DependentValueBinding="{Binding MarketValue}"
                            Margin="0,0,0,0" Style="{StaticResource ProportionsPieChart}" Width="Auto" Height="Auto" />
                </charting:Chart.Series>
            </charting:Chart>
        </StackPanel>
    </Border>
</UserControl>
